package com.alcloud.springplus.exception;


import com.alcloud.springplus.base.ResponseCode;

/**
  * 
  * @className:      ApplicationException
  * @description:    系统统一异常
  * @date:           2018/12/5 9:38
  * @author:         AllG
  * @updateRemark:   更新说明
 */
public class ApplicationException extends RuntimeException {
	private static final long serialVersionUID = 1L;
	/** 错误代码 */
	private int code;

	/**
	 * @method  ApplicationException
	 * @description 构造方法
	 * @date: 2018/12/5 9:38
	 * @author: AllG
	 * @param
	 * @return
	 */
	public ApplicationException() {
	}
	
	/**
	 * @method  ApplicationException
	 * @description 通过ResponseCode 构造方法
	 * @date: 2018/12/5 9:38
	 * @author: AllG
	 * @param responseCode
	 * @return
	 */
	public ApplicationException(ResponseCode responseCode) {
		super(responseCode.getMessage());
		this.code = responseCode.getCode();
	}

	/**
	 * @method  ApplicationException
	 * @description 构造方法
	 * @date: 2018/12/5 9:39
	 * @author: AllG
	 * @param responseCode
	 * @param msgArgs
	 * @return 
	 */
	public ApplicationException(ResponseCode responseCode, Object... msgArgs) {
		super(String.format(responseCode.getMessage(), msgArgs));
		this.code = responseCode.getCode();
	}
	
	/**
	 * @method  ApplicationException
	 * @description 构造方法
	 * @date: 2018/12/5 9:40
	 * @author: AllG
	 * @param code
	 * @param message
	 * @return
	 */
	public ApplicationException(int code, String message) {
		super(message);
		this.code = code;
	}

	/**
	 * @method  ApplicationException
	 * @description 构造方法
	 * @date: 2018/12/5 9:40
	 * @author: AllG
	 * @param code
	 * @param message
	 * @param cause
	 * @return
	 */
    public ApplicationException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }


	public int getCode() {
		return code;
	}


	public void setCode(int code) {
		this.code = code;
	}

}
